<template>
	<view class="page-content">
		<view style="display: flex;flex-direction: column;flex:1" class="mt-20">
			<template v-if="platform_flag=='zhihu'">
				<edit-zhihu-keyword ref="editModel">
				</edit-zhihu-keyword>
			</template>
		</view>
		<view class="btmBox c_ffffff" @click="$u.throttle(doSub, 3000)">
			确认
		</view>
	</view>
</template>

<script>
	import {
		getKeyword,
		postKeyWord
	} from '@/config/api.js'

	export default {
		data() {
			return {
				id: "",
				platform_flag: "",
				keyword: null
			}
		},
		onLoad(op) {
			this.id = op.id;
			this.platform_flag = op.platform_flag;

			this.getData();
		},
		methods: {
			doSub() {
				var subData = this.$refs.editModel.getEditData();

				subData['id'] = this.keyword.id;
				subData['platform_flag'] = this.keyword.platform_flag;

				postKeyWord(subData).then(res => {
					uni.showToast({
						title: "操作成功!",
						duration: 2000,
						icon: 'success'
					})
				}).catch(err => {
					uni.showToast({
						title: err.info,
						duration: 2000,
						icon: 'none'
					})
				})
			},
			getData() {
				getKeyword({
					id: this.id,
					platform_flag: this.platform_flag
				}).then(res => {
					this.keyword = res;
					this.$refs.editModel.setData(res)
				}).catch(err => {

				})
			}
		}
	}
</script>

<style>

</style>
